function drawBgImg(bgUrl,canvas,complateCallBack){
    var context = canvas.getContext('2d');
    var height = canvas.height;
    var width = canvas.width;

    var img = new Image();
    // img.src = bgUrl;
    img.onload = function(){
        context.drawImage(this,0,0,width,height);
        context.drawImage(this,0,-height,width,height);
        if(complateCallBack){
            complateCallBack(img);
        }
    };
    img.src = bgUrl
}
//实现背景滚动
var bgOffset = 0;
function animateBackground(canvas,image){
    var speed = 5;
    var context = canvas.getContext('2d')
    var width = canvas.width;
    var height = canvas.height;

//    清除画布
    context.clearRect(0,0,canvas.width,canvas.height);

    //存储状态
    context.save();
//    更新位置
    bgOffset += speed;
    if(bgOffset>=height){
        bgOffset = 0;
    }
    context.translate(0,bgOffset)
//    绘制图片
    context.drawImage(image,0,0,width,height);
    context.drawImage(image,0,-height,width,height);

//    获取存储状态
    context.restore();
}
